package com.znf4.controller.search.lucene;

import org.springframework.stereotype.Service;


/**
 * 商品管理服务实现类
 */
@Service
public class IndexService  {

	/**
	 * 获取 商品
	 *//*
	@Autowired
	private  GoodService   goodService ;
	
	
	
	*//**
	 * 索引管理dao
	 *//*
	@Autowired
	private IndexDao indexDao;
	
	*//**
	 * 创建索引
	 * <p>Title: createIndexDump</p>
	 * <p>Description: </p>
	 * @see IndexService.itcast.lucene.service.ProductService#createIndexDump()
	 *//*
	public void createIndexDump() {
		//查询数据库获得全部商品
		List<Good_Type1_2_User> proList = goodService.selectAllGoods() ;
		for(Good_Type1_2_User gtu : proList){
			System.out.println("添加到索引中的数据 ：" + gtu );
		}
		//创建商品的全文索引
		indexDao.createDump(proList);
		
	}

	*//**
	 * 搜索商品
	 * @param queryString
	 * @param good_type2_name
	 * @param price
	 * @param page
	 * @param sort
	 * @return
	 *//*
	public GoodResult getProductList(String queryString, String good_type2_name,String price, Integer page, String sort) {
		//解析价格区间
		Double priceStart = null;
		Double priceEnd = null;
		if (price != null && !"".equals(price)) {
			String[] strPrice = price.split("-");
			//0-79 80-199
			if (strPrice.length == 2) {
				priceStart = new Double(strPrice[0]);
				priceEnd = new Double(strPrice[1]);
			//200以上
			} else if (strPrice.length == 1) {
				priceStart = new Double(strPrice[0]);
				//设定一个很大的数值
				priceEnd = new Double(99999999);
			}
		}
		GoodResult resultModel = indexDao.getProductList(queryString, good_type2_name, priceStart, priceEnd, page, sort);
		return resultModel;
	}
	
	
	
	*//**
	 * 实时索引
	 *//*
	public boolean  addIndexDocument(){
		
		 Map<String, Object>  paramsMap = new  HashMap<String, Object>() ;
		 paramsMap.put("good_time_start", DateUtil.getDay() ) ;
		 paramsMap.put("good_time_end", DateUtil.getDay()  ) ;
		 paramsMap.put("number", 10000) ;    // 设置上限值，查所有
		 List<Good_Type1_2_User>  lGood_Type1_2_Users = goodService.findGoodsBystart_end_time(paramsMap) ;
		
		 boolean flag = indexDao.addIndexDocument( lGood_Type1_2_Users );
		 
		 return flag ;
	}
	
*/
	
}
